//
//  TCLYTaskTableViewCell.m
//  YuErmuYing
//
//  Created by LYang on 16/8/20.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYTaskTableViewCell.h"
#import "Macros.h"
#import "Masonry.h"

@implementation TCLYTaskTableViewCell
-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]) {
        
        UIImageView * bgImageView = [[UIImageView alloc] init];
        bgImageView.backgroundColor = bgColor;
        [self addSubview:bgImageView];
        [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self);
            make.right.mas_equalTo(self);
            make.left.mas_equalTo(self);
            make.bottom.mas_equalTo(self);
        }];
        
        UIView * bgView = [[UIView alloc] init];
        bgView.backgroundColor = [UIColor whiteColor];
        [self addSubview:bgView];
        [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(6);
            make.left.mas_equalTo(self);
            make.right.mas_equalTo(self);
            make.bottom.mas_equalTo(self);
        }];
        
        self.taskNameLabel = [[UILabel alloc] init];
        self.taskNameLabel.font = [UIFont systemFontOfSize:12];
        self.taskNameLabel.textColor = blackFont;
        self.taskNameLabel.numberOfLines = 1;
        self.taskNameLabel.textAlignment = NSTextAlignmentLeft;
        [bgView addSubview:self.taskNameLabel];
//        [self.taskNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.mas_equalTo(self);
//            make.left.mas_equalTo(self.mas_left).offset(12);
//            
//        }];
        
        self.rewardLabel = [[UILabel alloc] init];
        self.rewardLabel.font = [UIFont systemFontOfSize:10];
        self.rewardLabel.textColor = grayFont;
        self.taskNameLabel.textAlignment = NSTextAlignmentCenter;
        [bgView addSubview:self.rewardLabel];
        [self.rewardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(bgView);
            make.left.mas_equalTo(self.taskNameLabel.mas_right).offset(6);
            make.width.mas_equalTo(45);
            make.height.mas_equalTo(20);
        }];
        
        self.taskBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.taskBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.taskBtn.backgroundColor = btnColor;
        self.taskBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        self.taskBtn.layer.cornerRadius = 5;
        self.taskBtn.layer.masksToBounds = YES;
        [bgView addSubview:self.taskBtn];
        [self.taskBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.mas_right).offset(-12);
            make.centerY.mas_equalTo(bgView);
            make.width.mas_equalTo(40);
            make.height.mas_equalTo(20);
        }];
    }
    return self;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
